package com.yufuchang;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by yufuchang on 2020/8/1.
 */
@RestController
public class HelloController {

    @GetMapping("/test")
    public ModelAndView test(){
        List<Book> books = new ArrayList<>();
        Book book1 = new Book(1,"yufuchang.com","yufuchang");
        Book book2 = new Book(1,"于富昌","yufuchang");
        books.add(book1);
        books.add(book2);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("books",books);
        modelAndView.setViewName("index");
        return modelAndView;
    }
}
